home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-01-15 | 11.5 KB | 281 lines | [TEXT/MPS ] |
- #------------------------------------------------------------------------------
- #
- # Macintosh Developer Technical Support
- #
- # Sample Control Panel Device and INIT Combination
- #
- # Program: INIT - CDEV
- # File: INIT - CDEV.make - Make Source
- #
- # Copyright © 1990 Apple Computer, Inc.
- # All rights reserved.
- #
- #------------------------------------------------------------------------------
-
- AppName = 'INIT - CDEV'
- Signature = 'INCD'
-
-
- #------------------------------------------------------------------------------
- #
- # Options for our compilers:
- #
- # -sym on:
- # tells the compilers and linker to emit symbol information for
- # a source level debugger, such as SADE.
- #
- # -case on:
- # tells the assembler to treat case differences in symbols as being
- # siginificant. We turn this on because we are dealing with C source
- # as well, which is also case-sensitive. If we were compiling with
- # Pascal, we'd probably turn case off so that we could reference
- # Pascal symbols without having to upper-case them all (which is how
- # Pascal exports its symbols).
- #
- # -r:
- # Tells the C compiler to require function prototypes. If it encounters
- # a function definition without first having seen a prototype for
- # it, it will mark it as an error.
- #
- # -b:
- # Tells the C compiler to embed literal strings in the C code. Normally,
- # string constants are stored in the global variables space and
- # references off of A5. Since are writing standalone code that
- # doesn't normally have an A5 globals space, we embed the strings into
- # the code and reference it off of the PC. There are ways of using
- # globals in standalone code, and we use them in the INIT part of
- # our show, but we don't in the CDEV, so we embed them.
- #
- # -mbg off:
- # tells the compilers to not emit low-level debugger names. This
- # saves on file space, but you may wish to remove this option if you
- # need to debug with something like Macsbug.
- #
- # -append:
- # means to add the resources to the target file, rather than
- # deleting all the ones that are there first.
- #
- # -msg nowarn:
- # Tells the Linker to not print any warning messages. When we link
- # our INIT and CDEV we link them with the same list of MPW libraries.
- # However, both the INIT and CDEV need a different set of libraries,
- # so we define the list of libraries to be the union of the needs of
- # the INIT and CDEV. This means that when we link, the linker will
- # tell us we are linking with some unnecessary libraries. Because we
- # don't care about those warnings, we turn them off with this option.
- #
- # -rt xxxx=####:
- # This tells the Linker what resource type to create. Normally, it puts
- # its output into CODE resources. Here, we tell it to put it into a
- # cdev=-4064 resource or an INIT=0 resource.
- #
- # -m <Procedure Name>:
- # This tells the Linker what the main entry point of our program is. If
- # you are using Pascal, this is normally the routine whose "END"
- # statement is followed by a period. If we are using C, then a main
- # routine is provided for us ("CMain" in CRuntime.o if using MPW 3.1,
- # or "%__Main" in Runtime.o if using MPW 3.2). However, when building
- # stand-alone code, we don't want to use those main procedures; they are
- # for applications only. Therefore, we provide our own entry point for
- # the Linker explicitly. When the Linker does its dead-code stripping, it
- # starts with this routine and does a treewalk. For applications, the
- # main entry point is given jump table location #1 so that the segment
- # loader can find it. Also note that the routine's name needs to be
- # all uppercased for Pascal routines.
- #
- # -sg <Segment Name>:
- # MPW only supports single segment standalone code. This means that
- # all of your executable code must belong to one segment. The easiest
- # way to make sure that all of your routines and libraries that they
- # use are put into one segment is to use the -sg <Segment Name> option.
- # Normally, you would say something like -sg <Segment Name>=<list of
- # segments>, which would merge those segments in the list into a single
- # segment with the name <Segment Name>. However, if you omit the list
- # of segments, ALL of your procedures will get put into <Segment Name>.
- #
- # -ra <Segment Name> = <attributes>:
- # Sets the resource attributes for the named resource. When INITs are
- # executed, they aren't locked by INIT 31. Because our INIT allocates
- # memory when installing its patch, we must make sure we are locked
- # down. If not, the code that is executing could be moved out from
- # under the PC.
- #
- #------------------------------------------------------------------------------
-
- SymOptions = #-sym on # turn this on to debug with SADE
-
- AOptions = -case on {SymOptions}
- COptions = -r -b -mbg off -d SystemSevenOrLater=1 {SymOptions}
- RezOptions = -append
- LinkOptions = -msg nowarn {SymOptions}
- CDEVLinkOptions = {LinkOptions} -rt cdev=-4064 -m TEXTCDEV -sg theCDEV
- INITLinkOptions = {LinkOptions} -rt INIT=0 -m INITInstall -sg theINIT ∂
- -ra theINIT=resLocked
-
-
- #------------------------------------------------------------------------------
- # These are modified default build rules. This is necessary to take into
- # account differences between MPW 3.1 and 3.2. The normal make rules include
- # everything below except that they don't have an {xAltOptions} variable.
- # We've added those variables to pass in flags that allow the source code
- # to use the appropriate symbols and definitions for the version of MPW
- # it's running under. We also add some snazzy echo statements that report
- # our progress.
- #------------------------------------------------------------------------------
-
- .a.o ƒ .a
- Echo " Assembling: {Default}.a"
- {Asm} {DepDir}{Default}.a -o {TargDir}{Default}.a.o {AOptions} {AAltOptions}
-
- .c.o ƒ .c
- Echo " Compiling: {Default}.c"
- {C} {DepDir}{Default}.c -o {TargDir}{Default}.c.o {COptions} {CAltOptions}
-
- .p.o ƒ .p
- Echo " Compiling: {Default}.p"
- {Pascal} {DepDir}{Default}.p -o {TargDir}{Default}.p.o {POptions} {PAltOptions}
-
-
- #------------------------------------------------------------------------------
- # These are the lists of objects that our sample creates. They are used in
- # dependency statements and link commands. Note that in the case of
- # INITObjects, the order of the objects is important. When we install the
- # patch into the System heap, we install everything from the first routine
- # in INIT.a.o to the end of the resource. This means that everything we
- # want to stay resident must be AFTER INIT.a.o, and everything that is not
- # needed after installation should be BEFORE INIT.a.o.
- #------------------------------------------------------------------------------
-
- CDEVObjects = ∂
- 'CDEV.c.o'
-
- INITObjects = ∂
- 'INITInstall.a.o' ∂
- 'ShowINIT.a.o' ∂
- 'INIT.a.o' ∂
- 'INIT.c.o' ∂
- 'SAGlobals.c.o'
-
-
- #------------------------------------------------------------------------------
- # These help define the libraries that we want to link with. {CLibs} holds
- # the libraries we want to link with under MPW 3.0 or MPW 3.1. Under MPW 3.2
- # and later, “CInterface.o” and “CRuntime.o” are merged with “Interface.o” and
- # “Runtime.o”. So, under 3.2 and later, we link with the files in {CLibs32}
- # instead. Note that we use the library routines defined in PLStringFuncs.h,
- # which requires us to include “PasLib.o” in our {CLibs} and {CLibs32}
- # variables.
- #------------------------------------------------------------------------------
-
- PLibs = ∂
- "{Libraries}Runtime.o" ∂
- "{UtilityFolder}"GestaltGlue.a.o ∂
- "{Libraries}Interface.o" ∂
- "{PLibraries}PasLib.o"
-
- PLibs32 = ∂
- "{Libraries}Runtime.o" ∂
- "{Libraries}Interface.o" ∂
- "{PLibraries}PasLib.o"
-
- CLibs = ∂
- "{CLibraries}CRuntime.o" ∂
- "{CLibraries}CInterface.o" ∂
- "{UtilityFolder}"GestaltGlue.a.o ∂
- "{Libraries}Interface.o" ∂
- "{PLibraries}PasLib.o"
-
- CLibs32 = ∂
- "{Libraries}Runtime.o" ∂
- "{Libraries}Interface.o" ∂
- "{PLibraries}PasLib.o"
-
-
- #------------------------------------------------------------------------------
- # Dependencies for the individual components. These will invoke the
- # default build rules listed in Chapter 9 of the MPW 3.0 manual.
- #
- # The below dependency says that all of the object listed in {CDEVObjects} and
- # {INITObjects} are dependent on this makefile and “Common.h”.
- #------------------------------------------------------------------------------
-
- {CDEVObjects} {INITObjects} ƒ {AppName}.make Common.h
-
-
- #------------------------------------------------------------------------------
- # This is a dummy dependency rule. This will always be executed. This dummy
- # rule must be the first for {AppName} so that it will be executed first.
- # This is necessary to make evaluations that are beyond the scope of
- # Make. These evaluations will be performed by the Shell at execution time,
- # and they must execute first because compile and link command lines depend
- # on variables set up by these evaluations. This has the unfortunate side
- # effect that Make will always consider {AppName} to be out of date. It will
- # always, at a minimum, execute the commands for the target ShellForce.
- #
- # Also note that we turn Echo off here. This is turned on if you execute
- # your make scripts from the "Build" menu (which almost everyone does). We
- # turn it off so that you don't have to see any of the instructions that
- # determine library sets, etc. We also won't have to see the commands that
- # are being used to invoke the C compiler, etc., which can look pretty
- # gnarly if you have lots of command line options.
- #------------------------------------------------------------------------------
-
- {AppName} ƒƒ ShellForce
-
- # With the above rule, {AppName} will always be out of date with respect to
- # the non-existent file ShellForce. This will force the following commands to
- # be executed.
- ShellForce ƒ
- Set Echo 0
- IF "{ShellVersion}" == ""
- ( EVALUATE "`Version`" =~ /MPW Shell≈ ([0-9]+(.[ab0-9]+)+)®1≈/ ) ∑ Dev:Null
- SET ShellVersion "{®1}"
- END
- IF "{ShellVersion}" =~ /3.[01]≈/
- SET AAltOptions "-d MPW31=1"
- SET CAltOptions "-d MPW31=true"
- SET PAltOptions "-d MPW31=TRUE"
- SET CSysObjects "`QUOTE {CLibs}`"
- SET PSysObjects "`QUOTE {PLibs}`"
- ELSE
- SET AAltOptions "-d MPW31=0"
- SET CAltOptions "-d MPW31=false"
- SET PAltOptions "-d MPW31=FALSE"
- SET CSysObjects "`QUOTE {CLibs32}`"
- SET PSysObjects "`QUOTE {PLibs32}`"
- END
-
-
- #------------------------------------------------------------------------------
- # Build rule that links our application together. If any of our objects
- # changes, or this makefile changes, then we relink. The dummy prerequisite
- # ShellForce must come before any other prerequisites for {AppName}.
- #------------------------------------------------------------------------------
-
- {AppName} ƒƒ {CDEVObjects}
- Echo " Linking: CDEV"
- Link {CDEVLinkOptions} -o {Targ} {CDEVObjects} {CSysObjects}
- SetFile {Targ} -t cdev -c {Signature} -a B
-
- {AppName} ƒƒ {INITObjects}
- Echo " Linking: INIT"
- Link {INITLinkOptions} -o {Targ} {INITObjects} {CSysObjects}
- SetFile {Targ} -t cdev -c {Signature} -a B
-
-
- #------------------------------------------------------------------------------
- # Build rule that creates our resources and adds them to the application
- #------------------------------------------------------------------------------
-
- {AppName} ƒƒ {AppName}.make ∂
- 'CDEV.rsrc'
- Echo " Merging: CDEV.rsrc"
- Echo 'include "CDEV.rsrc";' | Rez {RezOptions} -o {AppName}
-
- #------------------------------------------------------------------------------
- # Build rule that copies our CDEV to the System Folder when it's all built.
- #------------------------------------------------------------------------------
-
- #{AppName} ƒƒ {CDEVObjects} {INITObjects} 'CDEV.rsrc' {AppName}.make
- # Duplicate -y {AppName} "{SystemFolder}"
-